
define(["jquery"], function () {
    'use strict'
    function getBrandListData(){
        // let url = "pxx/";
        // let data = {
        //     subject_id: 5578,
        //     page: 1,
        //     size: 40,
        //     // province_id: 25,
        //     // platform: 1,
        //     // pdduid: 0
        // }
        let url = "http://zhaoyx0907.com/pxx";
        $.ajax(url,
            {
                // data: data,
                dataType: "json"
            }
        ).then(function (res) {
            // console.log(res);
            renderBrandList(res);
        })
    }
    function render(res,container) {
        var reduce=3;
        var html = "";
        var count=0;
        for (var i = 0; i < res.length; i++) {
            if(count>=4) break;
            if(typeof res[i].image_url =="undefined") continue;
            // console.log(res[i].image_url)
            var last=i%5===0?"last":"";
            html = html +
                `<div class="brand_product ${last}">
                <div class="brandimg">
                      <a href="./detail.html?${res[i].goods_id}"><img
                                  src="${res[i].image_url}"
                                  alt=""></a>
                      <span class="residuce"><i class="iconfont icon_spport"></i><span>剩余 0 天 00时 00分
                                  00秒</span></span>
                </div>
                <div class="brandTitle">
                      <span class="title">${res[i].short_name}</span>
                      <div class="status_container">
                            <span class="status">进入活动</span>
                      </div>

                </div>
          </div>`
          count+=1;
        }
        container.html(html);
       
    }
    function renderBrandList(data) {
        var container=$(".brand_main");
        console.log(data.goods_list);
        render(data.goods_list,container);
        
    }
    function brand(){
        getBrandListData();
    }
    return brand;

})